<template>
  <div class="edit">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>兑换码详情</span>
        <el-button @click="$router.go(-1)" style="float: right; padding: 3px 0" type="text">返回</el-button>
      </div>
      <el-form ref="form" label-width="120px" size="mini">
        <el-form-item label="编号">
          {{info.id}}
        </el-form-item>
        <el-form-item label="兑换码">
          {{info.exchangeCode}}
        </el-form-item>
        <el-form-item label="APIKEY">
          {{info.apiKey}}
        </el-form-item>
        <el-form-item label="产品名称">
          {{info.goodsName}}
        </el-form-item>
        <!--todo:规格-->
        <el-form-item label="产品规格">
           {{info.goodsStandard && info.goodsStandard.desc}} 
        </el-form-item>
        <el-form-item label="状态">
          {{info.codeStatus | filterStatus}}
        </el-form-item>
        <el-form-item label="兑换人昵称">
          <el-button type="text">{{info.useNickName}}</el-button>
        </el-form-item>
        <!--todo:兑换人账号-->
        <el-form-item label="兑换人账号">
          {{info.useUserName}}
        </el-form-item>
        <el-form-item label="兑换时间">
          {{info.useTime}}
        </el-form-item>
        <el-form-item label="生成人">
          {{info.createNickName}}
        </el-form-item>
        <el-form-item label="生成时间">
          {{info.createTime}}
        </el-form-item>
        <el-form-item label="有效截止日期">
          {{info.endTime}}
        </el-form-item>
        <el-form-item label="备注">
          {{info.codeDesc}}
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>
<script>
  import {getExchangeCode} from "@/api/system/exCode";
  export default {
    data() {
      return {
        info: {}
      };
    },
    filters: {
      // 状态(0：未兑换1：已兑换2：已禁用3：已过期)
      filterStatus(value) {
        return {
          0: '未兑换',
          1: "已兑换",
          2: "已禁用",
          3: "已过期"
        }[value];
      }
    },
    mounted() {
      this.getInfo()
    },
    methods: {
      getInfo() {
        let id = this.$route.params.id
        getExchangeCode(id).then(res => {
          
          if (res.data.goodsStandard) {
            res.data.goodsStandard = JSON.parse(res.data.goodsStandard)
          }

          this.info = res.data
          console.log(this.info)
        })
      }
    }
  };
</script>
<style lang="scss" scoped>

</style>
